To implement secure data transition in Home and Building Automation (HBA), an encryption and authentication mechanism was introduced into Konnex/European Installation Bus (KNX/EIB). Diffie-Hellman algorithm was used to realize asymmetric key sharing, Advanced Encryption Standard (AES) was applied to data encryption, Hash algorithm was adopted for challenge authentication, a device named controller was employed to coordinate the procedure of key sharing and device authentication. The simulation results show the proposed method is feasible concerning the space and time cost. Compared to other improvement methods, this one is easier to implement and operate, and it can ensure data security.